package com.online.onlineshop.utils;

/**
 * @author zihao.wang1
 * @date 2022/3/9
 */
public class ReturnData<T> {

    public static ReturnData<String> SUCCESS = new ReturnData<>(ReturnCode.SUCCESS);

    private String code;
    private String msg;
    private T t;
    /** 数据总数 */
    private long count;
    /** 页码 */
    public long pageNum;

    public ReturnData(ReturnCode returnCode) {
        this.code = returnCode.getCode();
        this.msg = returnCode.getMsg();
    }

    public ReturnData(ReturnCode returnCode, String msg) {
        this.code = returnCode.getCode();
        this.msg = msg;
    }

    public ReturnData(ReturnCode returnCode, T t) {
        this.code = returnCode.getCode();
        this.msg = returnCode.getMsg();
        this.t = t;
    }

    public ReturnData(T t) {
        this.code = ReturnCode.SUCCESS.getCode();
        this.msg = ReturnCode.SUCCESS.getMsg();
        this.t = t;
    }

    public ReturnData(T t, long count) {
        this.code = ReturnCode.SUCCESS.getCode();
        this.msg = ReturnCode.SUCCESS.getMsg();
        this.count = count;
        this.t = t;
    }

    public ReturnData(T t, long count, long pageNum) {
        this.code = ReturnCode.SUCCESS.getCode();
        this.msg = ReturnCode.SUCCESS.getMsg();
        this.count = count;
        this.pageNum = pageNum;
        this.t = t;
    }

    public T getData() {
        return t;
    }

    public void setData(T data) {
        this.t = data;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public long getCount() {
        return count;
    }

    public long getPageNum() {
        return pageNum;
    }

}